home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DDJMAG / DDJ9203.ZIP / XSHARP.ZIP / MOVEPOLY.C < prev    next >
Text File  |  1991-12-26  |  1KB  |  33 lines

  1. /* Rotates and moves a polygon-based object around the three axes.
  2.    Movement is implemented only along the Z axis currently. */
  3. #include "polygon.h"
  4.  
  5. void RotateAndMovePObject(PObject * ObjectToMove)
  6. {
  7.    if (--ObjectToMove->RDelayCount == 0) {   /* rotate */
  8.       ObjectToMove->RDelayCount = ObjectToMove->RDelayCountBase;
  9.       if (ObjectToMove->Rotate.RotateX != 0.0)
  10.          AppendRotationX(ObjectToMove->XformToWorld,
  11.                ObjectToMove->Rotate.RotateX);
  12.       if (ObjectToMove->Rotate.RotateY != 0.0)
  13.          AppendRotationY(ObjectToMove->XformToWorld,
  14.                ObjectToMove->Rotate.RotateY);
  15.       if (ObjectToMove->Rotate.RotateZ != 0.0)
  16.          AppendRotationZ(ObjectToMove->XformToWorld,
  17.                ObjectToMove->Rotate.RotateZ);
  18.       ObjectToMove->RecalcXform = 1;
  19.    }
  20.    /* Move in Z, checking for bouncing */
  21.    if (--ObjectToMove->MDelayCount == 0) {
  22.       ObjectToMove->MDelayCount = ObjectToMove->MDelayCountBase;
  23.       ObjectToMove->XformToWorld[2][3] += ObjectToMove->Move.MoveZ;
  24.       if ((ObjectToMove->XformToWorld[2][3] >
  25.             ObjectToMove->Move.MaxZ) ||
  26.             (ObjectToMove->XformToWorld[2][3] <
  27.             ObjectToMove->Move.MinZ) ) {
  28.          ObjectToMove->Move.MoveZ = -ObjectToMove->Move.MoveZ;
  29.       }
  30.       ObjectToMove->RecalcXform = 1;
  31.    }
  32. }
  33.